#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
import traceback

from flask import Response


def register_except_handle(app):
    @app.errorhandler(Exception)
    def except_handle(exc):
        print(traceback.format_exc())
        return json.dumps({
            'code': 200,
            'message': str(exc)
        }, ensure_ascii=False), 200
